var t = getApp();

Component({
    properties: {
        plugin: {
            type: null
        },
        goods_info: {
            type: null
        }
    },
    data: {
        addressName: "",
        showAddressList: !1,
        yzaddressInfo: [],
        state: 1,
        judgmentOptionId: null
    },
    lifetimes: {
        attached: function() {
            this.txtComputed(), this.properties.plugin && this.firstGetData();
        },
        ready: function() {},
        detached: function() {}
    },
    methods: {
        showAddressShow: function() {
            this.setData({
                showAddressList: !0
            }), console.log(this.data.showAddressList, "aaaaaaaaa");
        },
        confirmSelectAddress: function(t) {
            var s = t.detail;
            this.setData({
                yzaddressInfo: s
            });
            var a = "".concat(this.data.yzaddressInfo.province).concat(this.data.yzaddressInfo.city).concat(this.data.yzaddressInfo.district).concat(this.data.yzaddressInfo.street).concat(this.data.yzaddressInfo.address);
            this.setData({
                addressName: a,
                showAddressList: !1
            }), this.getData(), this.tapMrAdress(s);
        },
        tapMrAdress: function(s) {
            var a = {
                username: s.username,
                mobile: s.mobile,
                province: s.province,
                city: s.city,
                district: s.district,
                address: s.address,
                isdefault: 1,
                address_id: s.id
            }, e = t.getNetAddresss("member.member-address.update");
            t._postNetWork({
                url: e,
                data: a,
                success: function(t) {
                    t.data.result;
                }
            });
        },
        txtComputed: function() {
            var t = "";
            this.data.plugin.member_address && (this.data.plugin.member_address.forEach(function(s) {
                1 == s.isdefault && (t = "".concat(s.province).concat(s.city).concat(s.district).concat(s.street).concat(s.address));
            }), this.setData({
                addressName: t
            }), console.log(this.data.plugin, this.addressName, "aaaaaaaa1111"));
        },
        firstGetData: function() {
            var t = [];
            this.data.plugin.member_address.length > 0 && (this.data.plugin.member_address.forEach(function(s) {
                1 == s.isdefault && (t = s);
            }), this.judgmentOptionId || this.setData({
                judgmentOptionId: this.data.goods_info.get_goods.has_many_options[0].id
            }), this.setData({
                yzaddressInfo: t
            }), this.getData());
        },
        getData: function() {
            var s = this, a = this.data.yzaddressInfo, e = {
                goods_id: this.data.goods_info.get_goods.id,
                goods_option_id: this.data.judgmentOptionId,
                username: a.username,
                mobile: a.mobile,
                province: a.province,
                city: a.city,
                district: a.district,
                address: a.address
            }, d = t.getNetAddresss("plugin.jd-supply.frontend.goods.option.inStock");
            t._postNetWork({
                url: d,
                data: e,
                success: function(t) {
                    var a = t.data;
                    1 == a.result && (s.setData({
                        state: a.data.status
                    }), s.triggerEvent("addressState", s.data.state));
                }
            });
        }
    }
});